<!DOCTYPE html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<p id="text">
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
</p>
<script>
    var testElem = document.getElementById("text");
    testElem.addEventListener("mousemove", function(event) {
      event.preventDefault();
    }, false);

    var testCancelledMouseMoveSelect = async_test('Tests whether cancelled mousemove can start text selection.');

    if (window.chrome && chrome.gpuBenchmarking) {
      var rect = testElem.getBoundingClientRect();
      var text_x = rect.left;
      var text_y = rect.top + rect.height / 2;

      var pointerActions =
        [{source: "mouse",
          actions: [
            { name: "pointerDown", x: text_x + 10, y: text_y },
            { name: "pointerMove", x: text_x + 50, y: text_y },
            { name: "pointerMove", x: text_x + 150, y: text_y },
            { name: "pointerMove", x: text_x + 200, y: text_y },
            { name: "pointerUp" }]}];
      chrome.gpuBenchmarking.pointerActionSequence(pointerActions, () => {
        testCancelledMouseMoveSelect.step(function() {
          assert_greater_than(window.getSelection().toString().length, 0);
        })
        testCancelledMouseMoveSelect.done();
      });

    }
</script>

